// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hi_cache/hi_cache.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'un_knowo_page.dart';

void main() {
  /// 测试HiCache的存储和读取
  test('测试HiCache', () async {
    TestWidgetsFlutterBinding.ensureInitialized();
    SharedPreferences.setMockInitialValues({});
    await HiCache.preInit();
    var key = "testHiCache", value = "Hello.";
    HiCache.getInstance().setString(key, value);
    expect(HiCache.getInstance().get(key), value);
  });

  /// Widget测试
  testWidgets('测试UnKnownPage', (WidgetTester tester) async {
    // UnKnownPage虽然没有Flutter框架之外的依赖，但应为用到了Scaffold所以乣用MaterialApp宝贵
    await tester.pumpWidget(MaterialApp(
      home: UnKnownPage(),
    ));
    expect(find.text('404'), findsOneWidget);
  });
}
